package co.com.capsula.pages;

import java.util.Date;

import javax.servlet.http.HttpSession;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.RequestGlobals;

import co.com.capsula.beans.Persona;

/**
 * Start page of application tutorial1.
 */
public class Index {
	
	@Inject
	private Persona persona;
	
	@Inject
	private ComponentResources resources;
	
	@Inject
    private RequestGlobals requestGlobals;
	
	@ApplicationState
    private String login;
	
	public Date getCurrentTime() { 
		System.out.println(persona.getStrNombre());
		
		return new Date();
	}
	
	public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }
	

	@OnEvent(component = "logout")
	public Link onLogout() {
		HttpSession session = requestGlobals.getHTTPServletRequest().getSession();
		session.invalidate();
		return resources.createPageLink("login", false);  
	}
}